package com.itheima.reggie.dao;

import com.itheima.reggie.entity.Setmeal;
import com.itheima.reggie.entity.dto.SetmealDto;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface SetmealDao {
    @Select("select count(*) from setmeal where category_id=#{cateId}")
    Integer findCountByCateId(Long cateId);

    @Insert("insert into setmeal values(null,#{categoryId},#{name},#{price},#{status},#{code},#{description},#{image},#{createTime},#{updateTime},#{createUser},#{updateUser},0)")
    @Options(useGeneratedKeys = true, keyColumn = "id", keyProperty = "id")
    void add(SetmealDto setmealDto);

    List<Setmeal> getByPage(String name);

    int findCountByIds(@Param("ids") List<Long> ids);

    void delByIds(@Param("ids") List<Long> ids);

    @Select("select * from setmeal where category_id=#{categoryId} and status=#{status}")
    List<Setmeal> lst(Long categoryId, Integer status);
}
